package com.syt.dome.controller;

import com.syt.commer.Result;
import com.syt.dome.service.ScheduleService;
import com.syt.entity.model.hosp.Schedule;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/syt/hosp/schedule")
//@CrossOrigin// 跨域  使用了网关就不需要这个了
@Api(tags = "排班信息接口")
public class ScheduleController {

    @Autowired// 排班显示的接口
    private ScheduleService scheduleService;




    //    根据医院编号，科室编号和工作日期，查询排班详情信息
    @ApiOperation(value = "查询排班的详情信息")
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getScheduleDetail(@PathVariable String hoscode,
                                    @PathVariable String depcode,
                                    @PathVariable String workDate){


        // 查询详情信息
      List<Schedule> list=  scheduleService.getDetailSchedule(hoscode,depcode,workDate);

      return  Result.ok(list);

    }






    // 根据医院编号 和科室编号 查询排班的规则数据
    @ApiOperation(value = "查询排班的数据")
    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(
            @PathVariable long page,// 页数
            @PathVariable long limit,// 当前页
            @PathVariable String hoscode,// 科室
            @PathVariable String depcode// 排班
     ) {

        Map<String,Object> map =scheduleService.getRuleSchedule(page, limit,hoscode,depcode);
        System.out.println("=============================="+map);
        return Result.ok(map);
    }


    //根据医院编号 和 科室编号 ，查询排班规则数据
    @ApiOperation(value ="查询排班规则数据副本")
    @GetMapping("getScheduleRules/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRules(@PathVariable long page,
                                  @PathVariable long limit,
                                  @PathVariable String hoscode,
                                  @PathVariable String depcode) {
        Map<String,Object> map
                = scheduleService.getRuleSchedules(page,limit,hoscode,depcode);
        return Result.ok(map);
    }

}
